package si.yun.utils;

/**
 * @ClassName JsonData
 * @description: 返回格式规范
 * @Author 崔晓晨
 * @Date 2021/5/5 16:11
 **/
public class JsonData {

    private int code;
    private String msg;
    private Object obj;

    public JsonData() {
    }

    public JsonData(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonData(String msg) {
        this.msg = msg;
    }

    public JsonData(Object obj) {
        this.obj = obj;
    }

    public JsonData(int code, String msg, Object obj) {
        this.code = code;
        this.msg = msg;
        this.obj = obj;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getObj() {
        return obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    public static JsonData buildSuccess(Object data){
        return new JsonData(0,"",data);
    }

    public static JsonData buildError(String msg){
        return new JsonData(-1,msg);
    }

}
